<template>
  <g-add-form title="修改密码" :formAttrs="cols" @saveData="saveData" :width="450" :is="isshow" :isModel="true"
    :formInfo="formInfo" :showCancelBtn="false" :center="() => 'center'" @close="handleClose()">
  </g-add-form>
</template>

<script>
export default {
  props: {
    formInfo: { type: Object, default: () => { } },
    cols: {
      type: Object,
      default: () => {
        return {
          userId: { title: "用户编号", edit: false, val: 0 },
          userName: { title: "用户名", disable: true },
          oldPassword: { title: "原始密码", required: true, password: true },
          password: { title: "用户密码", required: true, password: true },
          confirmPassord: {
            title: "确认密码",
            required: true,
            password: true,
            trigger: "change",
            validate: (val, form) => {
              return val === form.password ? true : "密码不一样";
            },
          },
        };
      },
    },
  },
  data() {
    return {
      isshow: "g-add-form",
    };
  },
  methods: {
    handleClose(h = () => { this.isshow = undefined }) {
      let flag = true;
      this.$emit('close', (r = true) => {
        flag = r;
        if (flag) {
          h()
        }
      })
      if (flag) { h() }
    },
    saveData(data) {
      this.$emit("changePassword", data, (v = true) => {
        if (v == true) {
          this.handleClose();
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped></style>